﻿//-----------------------------------------------------------------------
// <copyright file="AllCars.aspx.cs" company="CMSN Software">
//    Copyright © 2010  CMSN Software
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see http://www.gnu.org/licenses.
// </copyright>
//-----------------------------------------------------------------------
        
namespace CMSNSoftwareTutorials.ChangeTheUrlInAjaxApplications
{
    using System;

    /// <summary>
    /// code behind of the AllCars.aspx. this is containing the car details
    /// </summary>
    public partial class AllCars : System.Web.UI.Page
    {
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            string allCars = string.Empty;
            foreach (Car itm in CarStore.AllCars())
            {
                allCars += "<div class='car-information'>";
                allCars += "<div>" + itm.Make + "</div>";
                allCars += "<div>" + itm.Model + "</div>";
                allCars += "<div>" + itm.Year + "</div>";
                allCars += "<div>" + itm.Doors + "</div>";
                allCars += "<div>" + itm.Color + "</div>";
                allCars += "<div>" + itm.Price + "</div>";
                allCars += "<div><a href='carInfo.aspx?carid=" + itm.Id + "'>view details</a></div>";
                allCars += "</div>";
            }

            this.CarInformationContainer.Text = allCars;
        }
    }
}